package core.handler;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Objects;
import java.util.logging.Handler;

/**
 * 结果集处理
 *
 * @author Feny
 * @date Created in 2022/4/26
 */
public interface RowMapper<T> {
    T mapRow(ResultSet resultSet) throws SQLException;

    default String getColumn(ResultSetMetaData data, int index) throws SQLException {
        String column = data.getColumnLabel(index);
        if (Objects.isNull(column) || column.isEmpty()) {
            data.getColumnName(index);
        }
        return column;
    }
}
